import { Injectable } from '@angular/core';
// import { HttpClient } from '@angular/common/http';

import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'

import { HttpRequestService } from '../../core/services/http-request.service';

@Injectable()
export class FooService {
    constructor(private httpRequestService: HttpRequestService) { }

    get(): Observable<any> {
        return this.httpRequestService.get<any>('/foo/get', { id: 17, name: 'YU-get' });
    }

    save(): Observable<any> {
        return this.httpRequestService.post<any>('/foo/save', { id: 18, name: 'YU-post' });
    }

    loadUser(pageStart: number, pageSize: number): Observable<any[]> {
        return this.httpRequestService.getWithoutBaseUrl<any[]>('assets/demo-data/user.json');
    }

    // getTree(): Observable<TreeNode> {
    //     return this.httpRequestService.getWithoutBaseUrl<TreeNode>('assets/demo-data/tree-data.json').pipe(map(response => {
    //         return (response as TreeNode[]).find(p => p.label === 'Movies');
    //     }));
    // }

    // loadTree(): Observable<TreeNode[]> {
    //     return this.httpRequestService.getWithoutBaseUrl<TreeNode[]>('assets/demo-data/tree-data.json');
    // }

    // loadEvent(): Observable<TreeNode[]> {
    //     return this.httpRequestService.getWithoutBaseUrl<TreeNode[]>('assets/demo-data/event.json');
    // }
}